<ion-view view-title="对话">
  <ion-nav-buttons side="right">
    <button ng-click="chats.showNewChatModal()" class="button button-clear button-positive button-icon ion-ios-compose-outline"></button>
  </ion-nav-buttons>

  <ion-content>
    <ion-list>
      <ion-item
              ng-repeat="chat in chats.data | orderBy:'-lastMessage.timestamp'"
              class="item-chat item-remove-animate item-avatar item-icon-right"
              type="item-text-wrap"
              href="#/tab/chats/{{chat._id}}">
        <img ng-src="{{chat | chatPicture}}">
        <h2>{{chat | chatName}}</h2>
        <ng-switch on="chat.lastMessage.type">
          <p ng-switch-when="text">{{chat.lastMessage.text}}</p>
          <p ng-switch-when="picture">图片</p>
        </ng-switch>
        <span class="last-message-timestamp">{{chat.lastMessage.timestamp | calendar}}</span>
        <i class="icon ion-chevron-right icon-accessory"></i>
        <ion-option-button class="button-assertive" ng-click="chats.remove(chat)">
          删除
        </ion-option-button>
      </ion-item>
    </ion-list>
  </ion-content>
</ion-view>

